﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace Shion.Lua
{
    public partial class LuaConsole : DockContent
    {
        public LuaConsole()
        {
            InitializeComponent();
            textBox2.AppendText("Welcome to Shion 6 Lua Console" + Environment.NewLine);
            textBox2.AppendText("(C) 2009 NasuTek Systems" + Environment.NewLine + Environment.NewLine);
            textBox2.AppendText("LuaInterface Version: " + typeof(LuaInterface.Lua).Assembly.GetName().Version.ToString() + Environment.NewLine + Environment.NewLine);
        }

        private void LuaConsole_Load(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                LuaInterface.Lua engine = new LuaInterface.Lua();
                engine.RegisterFunction("Shion_LuaConsole_SHION", this, GetType().GetMethod("Shion_LuaConsole_SHION"));

                textBox2.AppendText("> " + textBox1.Text + Environment.NewLine + Environment.NewLine);
                engine.DoString(textBox1.Text);
                textBox1.Clear();
            }
            catch (Exception ex)
            {
                textBox2.AppendText(ex.ToString() + Environment.NewLine + Environment.NewLine);
            }
        }

        public void Shion_LuaConsole_SHION(string easter)
        {
            if (easter == "shion")
            {
                new EasterEgg().Show();
            }
        }
    }
}